package fr.inserm.u915.organifooyi.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity(name="history")
@Table(name="history")
@NamedQueries({
    @NamedQuery(name="history.find.by.type.and.id",
            query="select H from history as H where H.objectType= :objectType and H.objectId = :objectId order by H.creation ")
   	})

public class History extends AbstractPersistentObject
	{
	@Column(name="objectType")
	private DataType objectType;
	@Column(name="objectId")
	private Long objectId;
	@Column(name="objectVersion")
	private Long objectVersion;
	@Column(name="fieldName",length=30)
	private String fieldName;
	@Column(name="fieldClass",length=30)
	private String fieldClass;
	@Column(name="oldLiteral")
	private String oldLiteral;
	@Column(name="newLiteral")
	private String newLiteral;
	@Column(name="label")
	private String label;
	
	
	
	public History(DataType objectType, Long objectId, Long objectVersion,
			String fieldName,
			String fieldClass, String oldLiteral, String newLiteral,
			String label) {
		this.objectType = objectType;
		this.objectId = objectId;
		this.objectVersion = objectVersion;
		this.fieldName = fieldName;
		this.fieldClass = fieldClass;
		this.oldLiteral = oldLiteral;
		this.newLiteral = newLiteral;
		if(label==null) label="\""+oldLiteral+"\"->\""+newLiteral+"\"";
		this.label = label;
		}
	public History()
		{
		
		}
	
	public DataType getObjectType() {
		return objectType;
	}
	public void setObjectType(DataType objectType) {
		this.objectType = objectType;
	}
	public Long getObjectId() {
		return objectId;
	}
	public void setObjectId(Long objectId) {
		this.objectId = objectId;
	}
	public Long getObjectVersion() {
		return objectVersion;
	}
	public void setObjectVersion(Long objectVersion) {
		this.objectVersion = objectVersion;
	}
	public String getFieldClass() {
		return fieldClass;
	}
	public void setFieldClass(String fieldClass) {
		this.fieldClass = fieldClass;
	}
	public String getOldLiteral() {
		return oldLiteral;
	}
	public void setOldLiteral(String oldLiteral) {
		this.oldLiteral = oldLiteral;
	}
	public String getNewLiteral() {
		return newLiteral;
	}
	public void setNewLiteral(String newLiteral) {
		this.newLiteral = newLiteral;
	}
	public String getLabel() {
		return label;
	}
	public void setLabel(String label) {
		this.label = label;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}
	
	
	}
